import { Vector3 } from './../Math/Vector3';
import { getStream } from '../Core/connect'
import * as MathUtils from '../Math/MathUtils'

export class Tileset{
    readonly type: string
    name: string
    uuid: string
    position: Vector3
    url: string
    constructor(name: string, url: string){
        this.name = name
        this.type = 'Tileset'
        this.uuid = MathUtils.generateUUID()
        this.position = new Vector3(0, 0, 0)
        this.url = url
        // this.setTilesetUrl(url)
    }
    initTileset() {
        const stream = getStream()
        const str = {tilesFunction: 'initTileset', ids: `${this.type},${this.name},${this.uuid}`, url:`${this.url}`}
        stream.emitUIInteraction(str)
    }
    setTilesetUrl(url: string) {
        const stream = getStream()
        const str = {tilesFunction: 'setTilesetUrl', ids: `${this.uuid}`, url:`${url}`}
        stream.emitUIInteraction(str)
    }
    removeTileset() {
        const stream = getStream()
        const str = {tilesFunction: 'removeTileset', ids: `${this.uuid}`}
        stream.emitUIInteraction(str)
    }
    setLongLat(position:any){
        this.position = position
        const stream = getStream()
        const str = {tilesFunction: 'setLonLat', ids: `${this.uuid}`,position:`${this.position.x},${this.position.y},${this.position.z}`}
        stream.emitUIInteraction(str)
    }
}